#define declare_pntr_to_mat(mat,csize) (*mat)[csize]

#define unit_matrix(m)\
  (m)[0][0] = 1.0; (m)[0][1] = 0.0; (m)[0][2] = 0.0;\
  (m)[1][0] = 0.0; (m)[1][1] = 1.0; (m)[1][2] = 0.0;\
  (m)[2][0] = 0.0; (m)[2][1] = 0.0; (m)[2][2] = 1.0

#define matvecmult(m, v, mv)\
  (mv).x = (m)[0][0] * (v).x + (m)[0][1] * (v).y + (m)[0][2] * (v).z;\
  (mv).y = (m)[1][0] * (v).x + (m)[1][1] * (v).y + (m)[1][2] * (v).z;\
  (mv).z = (m)[2][0] * (v).x + (m)[2][1] * (v).y + (m)[2][2] * (v).z

#define vecmatmult(v, m, mv)\
  (mv).x = (m)[0][0] * (v).x + (m)[1][0] * (v).y + (m)[2][0] * (v).z;\
  (mv).y = (m)[0][1] * (v).x + (m)[1][1] * (v).y + (m)[2][1] * (v).z;\
  (mv).z = (m)[0][2] * (v).x + (m)[1][2] * (v).y + (m)[2][2] * (v).z

#define vecmat34mult(l, m, q)\
   (q).w =   (m)[0][0] * (l).x + (m)[1][0] * (l).y + (m)[2][0] * (l).z;\
   (q).v.x = (m)[0][1] * (l).x + (m)[1][1] * (l).y + (m)[2][1] * (l).z;\
   (q).v.y = (m)[0][2] * (l).x + (m)[1][2] * (l).y + (m)[2][2] * (l).z;\
   (q).v.z = (m)[0][3] * (l).x + (m)[1][3] * (l).y + (m)[2][3] * (l).z

#define matmatmult(m1, m2, m)\
  (m)[0][0] = (m1)[0][0] * (m2)[0][0] + (m1)[0][1] * (m2)[1][0] + (m1)[0][2] * (m2)[2][0];\
  (m)[0][1] = (m1)[0][0] * (m2)[0][1] + (m1)[0][1] * (m2)[1][1] + (m1)[0][2] * (m2)[2][1];\
  (m)[0][2] = (m1)[0][0] * (m2)[0][2] + (m1)[0][1] * (m2)[1][2] + (m1)[0][2] * (m2)[2][2];\
  (m)[1][0] = (m1)[1][0] * (m2)[0][0] + (m1)[1][1] * (m2)[1][0] + (m1)[1][2] * (m2)[2][0];\
  (m)[1][1] = (m1)[1][0] * (m2)[0][1] + (m1)[1][1] * (m2)[1][1] + (m1)[1][2] * (m2)[2][1];\
  (m)[1][2] = (m1)[1][0] * (m2)[0][2] + (m1)[1][1] * (m2)[1][2] + (m1)[1][2] * (m2)[2][2];\
  (m)[2][0] = (m1)[2][0] * (m2)[0][0] + (m1)[2][1] * (m2)[1][0] + (m1)[2][2] * (m2)[2][0];\
  (m)[2][1] = (m1)[2][0] * (m2)[0][1] + (m1)[2][1] * (m2)[1][1] + (m1)[2][2] * (m2)[2][1];\
  (m)[2][2] = (m1)[2][0] * (m2)[0][2] + (m1)[2][1] * (m2)[1][2] + (m1)[2][2] * (m2)[2][2]

  
  
